(introduction)
# Import 3rd party libraries
from matplotlib import pyplot as plt
import pandas as pd
import numpy as np
import seaborn as sns
# Import own libraries
import catcoocc
Lorem ipsum
toy_data = catcoocc.dataio.read_sequences("docs/cmudict.tsv")
toy_co = catcoocc.dataio.get_cooccs(toy_data)
toy_obs = catcoocc.dataio.get_observations(toy_co)
print(len(toy_data), len(toy_co), len(toy_obs))
mle = catcoocc.scorers.mle_scorer(toy_co)
xy, yx, alpha_x, alpha_y = catcoocc.scorers.scorer2matrix(mle)
#for pair in mle:
# print(pair, mle[pair])
print('x', alpha_x)
print('y', alpha_y)
def plot_scorer(scorer, alpha_x, alpha_y, title=None):
if not title:
title = ""
matrix = pd.DataFrame(scorer, index=alpha_y, columns=alpha_x)
sns.set(font_scale=2.5)
plt.figure(figsize=(25, 25))
ax = plt.subplot(111)
sns.heatmap(matrix, annot=True, linewidths=.5, center=0, ax=ax).set_title(title, fontsize=100)
plot_scorer(xy, alpha_x, alpha_y, "x->y")
134373 6981230 1131
x ["'", 'A', 'B', 'C',
'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', 'À', 'É']
y ['aɪ', 'aʊ', 'b', 'd', 'dʒ',
'eɪ', 'f', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'oʊ',
'p', 's', 't', 'tʃ', 'u',
'v', 'w', 'z', 'æ', 'ð',
'ŋ', 'ɑ', 'ɔ', 'ɔɪ', 'ɛ',
'ɝ', 'ɡ', 'ɪ', 'ɹ', 'ʃ',
'ʊ', 'ʌ', 'ʒ', 'θ']
/home/tresoldi/.local/lib/python3.5/site-
packages/pandas/core/computation/check.py:17: UserWarning: The
installed version of numexpr 2.4.3 is not supported in pandas and will
be not be used
The minimum supported version is 2.4.6
ver=ver, min_ver=_MIN_NUMEXPR_VERSION), UserWarning)
another
plot_scorer(yx, alpha_y, alpha_x, "y->x")
leftover
print("ok")
print(dir(catcoocc))
np.random.seed(0)
sns.set(font_scale=2.5)
uniform_data = np.random.rand(10, 12)
plt.figure(figsize=(25, 25))
ax = plt.subplot(111)
sns.heatmap(uniform_data,
annot=True,
linewidths=.5, center=0, ax=ax)
ok
['__author__', '__builtins__', '__cached__',
'__doc__', '__email__', '__file__',
'__loader__', '__name__', '__package__',
'__path__', '__spec__', '__version__',
'dataio', 'scorers']
<matplotlib.axes._subplots.AxesSubplot at 0x7fb29c3bbda0>